package com.lecture.java8.excel.dyr;

import com.alibaba.excel.EasyExcel;
import com.lecture.java8.excel.DemoDataListener;
import com.lecture.java8.excel.dyr.model.Result0321;
import com.lecture.java8.excel.model.FinanceResult0320;
import com.lecture.java8.excel.model.Result0320;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test0320 {
    public static void main(String[] args) {
        String dataResultFileName = "D:\\study\\tmp\\0320\\4\\最终结果-企业生命周期.xlsx";
        DemoDataListener<Result0320> dataResultListener = new DemoDataListener<>();
        EasyExcel.read(dataResultFileName, Result0320.class,dataResultListener).sheet().doRead();
        List<Result0320> resultList = dataResultListener.getDataList();

        Map<String,Result0320> resultMap = new HashMap<>();
        for (Result0320 result : resultList) {
            resultMap.put(result.getA() + "-" + result.getB(),result);
        }



        //Map<String, String> resultMap = resultList.stream().collect(Collectors.toMap(r -> r.getId() + "-" + r.getYear(), Result0320::getEast));

        String dataFileName = "D:\\study\\tmp\\0320\\4\\0320公司规模结果.xlsx";
        DemoDataListener<FinanceResult0320> dataListener = new DemoDataListener<>();
        EasyExcel.read(dataFileName, FinanceResult0320.class,dataListener).sheet().doRead();
        List<FinanceResult0320> financeList = dataListener.getDataList();
        for (FinanceResult0320 finance : financeList) {
            //finance.setZ(resultMap.get(finance.getA() + "-" + finance.getB()));
            if (resultMap.get(finance.getA() + "-"+finance.getB()) == null) {
                continue;
            }
        }

        EasyExcel.write("D:\\study\\tmp\\0320\\4\\生命周期结果.xlsx", FinanceResult0320.class)
                .sheet("a").doWrite(financeList);

    }
}
